package cn.edu.neusoft.neufooddemo.activity;

import android.os.CountDownTimer;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

/*import cn.bmob.sms.BmobSMS;
import cn.bmob.sms.exception.BmobException;
import cn.bmob.sms.listener.RequestSMSCodeListener;
import cn.bmob.sms.listener.VerifySMSCodeListener;*/
import cn.edu.neusoft.neufooddemo.R;

public class PhoneRegActivity extends BaseActivity {
    private Button btn_send, btn_reg;
    private EditText et_phone, et_password, et_checkNum;
    private boolean result = false;

    @Override
    protected void initViews() {
        setLayout(R.layout.activity_phone_reg);
        btn_reg = (Button) findViewById(R.id.reg);
        btn_send = (Button) findViewById(R.id.send);
        et_phone = (EditText) findViewById(R.id.user);
        et_password = (EditText) findViewById(R.id.password);
        et_checkNum = (EditText) findViewById(R.id.checkNum);
    }

    @Override
    void initEvents() {
     /*   btn_send.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //接收验证码到手机
                BmobSMS.requestSMSCode(PhoneRegActivity.this, et_phone.getText().toString(), "短信模板", new RequestSMSCodeListener() {
                    @Override
                    public void done(Integer integer, BmobException e) {
                        if (e == null) {
                            new CountDownTimer(60000, 1000) {
                                @Override
                                public void onTick(long millisUntilFinished) {
                                    btn_send.setText(millisUntilFinished / 1000 + "秒");
                                }

                                @Override
                                public void onFinish() {
                                    btn_send.setClickable(true);
                                    btn_send.setText("重新发送");
                                }
                            }.start();

                            showToast("验证码发送成功，请尽快验证");
                        } else {
                            Log.e("btn_send", e.toString());
                            showToast("验证码发送失败");
                        }
                    }
                });
            }
        });*/
        btn_reg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              //  if (checkPhone())
                    register();
            }

        });
    }
    @Override
    void initData() {
       // BmobSMS.initialize(this, "0391fa8fcc51ac703a60c6b3a4011c61");
    }
/*
    boolean checkPhone() {

        BmobSMS.verifySmsCode(PhoneRegActivity.this, et_phone.getText().toString(), et_checkNum.getText().toString(), new VerifySMSCodeListener() {

            @Override
            public void done(BmobException e) {
                // TODO Auto-generated method stub
                if (e == null) {
                    showToast("验证成功");
                    result = true;
                } else {
                    Log.e("btn_check", e.toString());
                    showToast("验证失败");
                }
            }
        });
        return result;
    }
*/

    public void register() {

    }


}
